<?php
require_once("../config/config.php");
session_name("miushake");
session_start();

try{

	$action = isset($_GET['a']) ? $_GET['a'] : "";


	/* Traitement par Requette HTTP (AJAX) */
	/*
	// Vérification connexion
	if (isset($_POST['mail'])) {
		$auth = Auth::getInstance();
	   	$return = $auth->verifierAuthentification($_POST['mail'], $_POST['passwd']);
		if ($return) {
			echo "Connexion en cours...";
			exit();
		} else {
			echo "E-mail ou mot de passe incorrect";
			exit();
		}
  	}
	
	$auth = Auth::getInstance();
	
	if (! $auth->estConnecte()) {
		echo "Zone non autorisée";
		exit();
  	}
*/
	switch($action) {
		
		 /* Recommandation next() */
		case "next":
			$recommandation = Recommandation::initialize(RECOMMANDATION_ALEATOIRE); 
			$title = $recommandation->next();
			echo "<youtube_id>{$title->getYoutubeId()}</youtube_id><name>{$title->getName()}</name><artist>{$title->getArtist()}</artist><id_title>{$title->getIdTitle()}</id_title>";
			break;
			
		default:
			//echo "erreur";
			break;
	}
	
} catch (Exception $e) {
	echo $e->getMessage() . "<pre>{$e->getTraceAsString()}</pre>";
}

?>
